package org.sbbs.examples.one2one.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.sbbs.base.model.UUIDBaseObject;

@Entity
@Table(name = "t_stock_detail_1")
public class StockDetail_1 extends UUIDBaseObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8882601435569113874L;
	// private String stockId;
	private Stock_1 stock;
	private String compName;
	private String compDesc;
	private String remark;
	private Date listedDate;

	public StockDetail_1() {
	}

	public StockDetail_1(Stock_1 stock, String compName, String compDesc, String remark, Date listedDate) {
		this.stock = stock;
		this.compName = compName;
		this.compDesc = compDesc;
		this.remark = remark;
		this.listedDate = listedDate;
	}

	/*
	 * @GenericGenerator(name = "generator", strategy = "foreign", parameters =
	 * 
	 * @Parameter(name = "property", value = "stock"))
	 * 
	 * @Id
	 * 
	 * @GeneratedValue(generator = "generator")
	 * 
	 * @Column(name = "STOCK_ID", unique = true, nullable = false) public String
	 * getStockId() { return this.stockId; }
	 * 
	 * public void setStockId(String stockId) { this.stockId = stockId; }
	 */

	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "STOCK_ID")
	public Stock_1 getStock() {
		return this.stock;
	}

	public void setStock(Stock_1 stock) {
		this.stock = stock;
	}

	@Column(name = "COMP_NAME", nullable = false, length = 100)
	public String getCompName() {
		return this.compName;
	}

	public void setCompName(String compName) {
		this.compName = compName;
	}

	@Column(name = "COMP_DESC", nullable = false)
	public String getCompDesc() {
		return this.compDesc;
	}

	public void setCompDesc(String compDesc) {
		this.compDesc = compDesc;
	}

	@Column(name = "REMARK", nullable = false)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "LISTED_DATE", nullable = false, length = 10)
	public Date getListedDate() {
		return this.listedDate;
	}

	public void setListedDate(Date listedDate) {
		this.listedDate = listedDate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((compDesc == null) ? 0 : compDesc.hashCode());
		result = prime * result + ((compName == null) ? 0 : compName.hashCode());
		result = prime * result + ((listedDate == null) ? 0 : listedDate.hashCode());
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		result = prime * result + ((stock == null) ? 0 : stock.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		StockDetail_1 other = (StockDetail_1) obj;
		if (compDesc == null) {
			if (other.compDesc != null)
				return false;
		} else if (!compDesc.equals(other.compDesc))
			return false;
		if (compName == null) {
			if (other.compName != null)
				return false;
		} else if (!compName.equals(other.compName))
			return false;
		if (listedDate == null) {
			if (other.listedDate != null)
				return false;
		} else if (!listedDate.equals(other.listedDate))
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		if (stock == null) {
			if (other.stock != null)
				return false;
		} else if (!stock.equals(other.stock))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "StockDetail [ compName=" + compName + ", compDesc=" + compDesc + ", remark=" + remark + ", listedDate=" + listedDate + "]";
	}

}
